<template>
  <div class="listt">
    <van-nav-bar
      title="商品列表"
      left-text="返回"
      left-arrow
      @click-left="$router.back()"
    >
      <template #right>
        <van-icon name="search" size="18" />
      </template>
    </van-nav-bar>
    <div class="list2">

   
    <div class="list" v-for="item in listr" :key="item.id">
      <div class="lists">
        <img :src="item.img_url" alt="" 
         @click="$router.push({path :`/layout/myspxiangqing/${item.id}`})"
        />
        <p>{{ item.title }}</p>
      </div>
      <div class="listx">
        <p>
          ￥{{ item.sell_price }} <i>￥{{ item.market_price }}</i>
        </p>
        <span
          >热卖中 <i>剩{{ item.stock_quantity }}件</i></span
        >
      </div>
    </div>
     </div>
  </div>
</template>

<script>
import { getgoodsData } from "../../apis/api";
export default {
  data() {
    return {
      listr: [],
      pageindexs: 1,
    };
  },
  async created() {
    const res = await getgoodsData(this.pageindexs);
    console.log(res);
    this.listr = res.message;
  },
};
</script>

<style lang="less" scoped>
div.listt {
  
  van-nav-bar {
    template {
    }
  }
.list2{
  display: flex;
  flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;

  div.list {
// display: flex;
    margin: 5px 10px 10px 5px;
    box-shadow: 2px 2px 5px rgb(156, 155, 155);
    height: 300px;
    width: 165px;
    // background-color: red;
    border: 3px solid #a1a1a1;
    border-radius: 5px;
    // display: flex;

    //  display: flex;
    // display: block;

    div.lists {
      // background-color: aliceblue;
      height: 220px;
      img {
        width: 100%;
        margin-top: 20px;
      }

      p {
        font-size: 13px;
        padding-top: 150px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
    }

    div.listx {
      background-color: #e0dede;
      p {
        color: rgb(231, 48, 48);
        display: flex;
        align-items: center;

        i {
          color: rgb(187, 184, 184);
          font-size: 10px;
          margin-left: 10px;
          text-decoration: line-through;
        }
      }

      span {
        display: flex;
        justify-content: space-between;
        padding: 0 10px;
        color: #a1a1a1;
        font-size: 15px;
        height: 27px;
        i {
        }
      }
    }
    }
  }
}
</style>
